// 用户相关后台接口
import request from '@/utils/request'
/**
 * 封装内容管理接口
 * @params 请求接口的参数
 *  */
export const getarticles = (params) => {
  return request({
    method: 'get',
    url: '/mp/v1_0/articles',
    params
  })
}
/**
 * 获取文章频道接口
 *  */
export const pusharticles = () => {
  return request({
    method: 'get',
    url: '/mp/v1_0/channels'
  })
}
/**
 * 删除接口
 * @params 请求接口的参数
 *  */
export const delarticles = (id) => {
  return request({
    method: 'DELETE',
    url: `/mp/v1_0/articles/${id}`
  })
}
/**
 * 素材管理接口
 * @params 获得素材图片的各种数据
 *  */
// 获取图片素材
export const getimages = (params) => {
  return request({
    method: 'get',
    url: '/mp/v1_0/user/images',
    params
  })
}
// 修改图片的收藏或全部
export const putimages = (id, collect) => {
  return request({
    method: 'put',
    url: `/mp/v1_0/user/images/${id}`,
    data: {
      collect
    }
  })
}
// 删除图片
export const delimages = (id) => {
  return request({
    method: 'DELETE',
    url: `/mp/v1_0/user/images/${id}`
  })
}
// 发表文章（新建）
export const upAddarticle = (params, data) => {
  return request({
    method: 'POST',
    url: '/mp/v1_0/articles',
    params,
    data
  })
}
// 5获取文章详情
export const getArticleDetail = function (id) {
  return request({
    url: `/mp/v1_0/articles/${id}`,
    method: 'GET'
  })
}
// 6.修改文章详情
export const updateArticle = function (id, params, data) {
  return request({
    url: `/mp/v1_0/articles/${id}`,
    method: 'PUT',
    params,
    data
  })
}
// 获取粉丝详情
export const getfans = function (params) {
  return request({
    url: '/mp/v1_0/followers',
    method: 'GET',
    params
  })
}
// 获取粉丝统计数据
export const follfans = function () {
  return request({
    url: '/mp/v1_0/statistics/followers',
    method: 'GET'
  })
}
// 获取用户个人资料
export const getprofile = function () {
  return request({
    url: '/mp/v1_0/user/profile',
    method: 'GET'
  })
}
// 编辑用户个人资料
export const upprofile = function (data) {
  return request({
    url: '/mp/v1_0/user/profile',
    method: 'PATCH',
    data: data
  })
}
/**
 * 修改头像
 * @param {*} formData  是一个FormData格式的对象
 */
export const moduserImage = (formData) => {
  return request({
    method: 'PATCH',
    url: '/mp/v1_0/user/photo',
    data: formData
  })
}
